{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# 第三章.神经网络\n",
    "<P>神经网络的作用在于解决各变量的权重问题。即神经网络可以自动地从数据中学习到合适的权重参数</P>\n",
    "<P>有一个函数h(x),该函数能将输入信号的加权总和转化为输出信号,则该函数为<strong>激活函数</strong>.神经网络使用激活函数\n",
    "达到转换输出信号的目的</P>"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 3.2.激活函数\n",
    "<p>神经网络中,使用sigmoid函数作为激活函数,进行信号的转换,转换后的信号被传送给下一个神经元</p>\n",
    "<P>阶跃函数是指一旦输入超过阈值,就切换输出的函数</P>"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 3.2.2.阶跃函数的实现"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "def step_function(x):\n",
    "    y = x>0 # x为numpy数组\n",
    "    return y.astype(np.int)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T07:53:27.344774300Z",
     "start_time": "2023-08-27T07:53:25.479290700Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-1  1  2]\n"
     ]
    }
   ],
   "source": [
    "# 解释step_function\n",
    "x = np.array([-1,1,2])\n",
    "print(x)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T07:53:51.358638300Z",
     "start_time": "2023-08-27T07:53:51.346620100Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[False  True  True]\n"
     ]
    }
   ],
   "source": [
    "y = x>0\n",
    "print(y)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T07:54:30.428534Z",
     "start_time": "2023-08-27T07:54:30.413488600Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0 1 1]\n"
     ]
    }
   ],
   "source": [
    "# 把布尔型数组转化为整型数组\n",
    "y = y.astype(int)\n",
    "print(y)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T07:56:11.858764100Z",
     "start_time": "2023-08-27T07:56:11.822769100Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 3.2.3.阶跃函数的图形"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAARbUlEQVR4nO3df4wc513H8c/Hexf6MyTgo6Q+G1vIpbUggXK4kSqUQGhrp6EWEn8kgQZCK8tSjFKJihgq6B/9C0VAVMWtsSIrFAoWUgM1lYtJJSB/VEF2QpLWCQ6HS+OLA7nQqkVJhW9mvvyxe5flPDO7tnd37pl7vyQrNzvjve8qz370+LvPM+uIEAAgfRuaLgAAMBoEOgC0BIEOAC1BoANASxDoANASU0394o0bN8bWrVub+vUAkKQnnnjilYiYKTvXWKBv3bpVp06daurXA0CSbH+z6hwtFwBoCQIdAFqCQAeAliDQAaAlCHQAaAkCHQBagkAHgJYg0AGgJQh0AGgJAh0AWoJAB4CWINABoCUIdABoiYGBbvuI7Zdtf73ivG1/2va87Wdsv3v0ZQIABhlmhv6wpF0153dL2t77s1fSZ6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mq7lStBDx7AelPRWSY/afsr2oaYLGpfeh7/7JZ1Q98PBv2pzmPe8V9KHJf187//vU72ZKxLCDB0AWoIZOgC0BIEOAC1BoANASxDoANASBDoAtASBDgAtQaADQEv8H3KLPY8+S91KAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "def step_function2(x):\n",
    "    return np.array(x>0,dtype=int)\n",
    "\n",
    "x = np.arange(-5,5,0.1)\n",
    "y = step_function2(x)\n",
    "plt.plot(x,y)\n",
    "plt.ylim(-0.1,1.1) # 指定y轴的范围\n",
    "plt.show()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T08:01:48.719297Z",
     "start_time": "2023-08-27T08:01:48.541299800Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 3.2.4 sigmoid函数的实现"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "data": {
      "text/plain": "array([0.26894142, 0.73105858, 0.88079708])"
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def sigmoid(x):\n",
    "    return 1/(1+np.exp(-x))\n",
    "\n",
    "x = np.array([-1,1,2])\n",
    "sigmoid(x)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T08:10:59.479246900Z",
     "start_time": "2023-08-27T08:10:59.460990900Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 432x288 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2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Rzrts7BHlW6H2VmRU55wq9ztHbYvF1x+Jrhth83dHymjXlIiISJVToIiJRQoV+/JZ6HcAjsfi6Y/E1Q2y+7qh4zZpDFxGJEhqhi4hECRW6iEiUUKGfBDP7qpk5MxvkdZZwM7N7zewtM9tkZk+ZWX+vM4WTmc01sxIzKzWzO7zOE25mNsLMXjKzbWa2xcxu9TpTbzGzODN7w8ye9TrLyVKhnyAzGwFcAOz2OksveQE4zTl3OrAduNPjPGFjZnHAYmAeMBG40swmepsq7PzAV5xzE4CzgJtj4DW/61Zgm9chQkGFfuLuA74GxMS7ys65551z/s7N14DhXuYJsxlAqXOuzDnnA5YD8z3OFFbOuX3OuQ2dX9fTUXB53qYKPzMbDlwMPOB1llBQoZ8AM7sU2OOc2+h1Fo9cB/zN6xBhlAeUd9muIAbK7V1mVgBMA173Nkmv+AUdA7OA10FCId7rAJHKzF4EcrvZ9U3gG8BHejdR+B3rNTvnnu485pt0/PP80d7M1susm8di4l9iZpYOPAl8yTl32Os84WRmlwCVzrn1Znau13lCQYV+FM6587t73MwmA6OAjWYGHVMPG8xshnNufy9GDLmjveZ3mdk1wCXAh110X8BQAYzosj0c2OtRll5jZgl0lPmjzrmVXufpBXOAS83sIiAZyDSzR5xzn/E41wnThUUnycx2AoXOub6yUtsJMbO5wM+Bc5xzVV7nCSczi6fjjd8PA3uAdcAC59wWT4OFkXWMTh4CapxzX/I6T2/rHKF/1Tl3iddZTobm0CVYvwEygBfMrNjMlngdKFw63/y9BXiOjjcHV0RzmXeaA1wFnNf537e4c+QqfYhG6CIiUUIjdBGRKKFCFxGJEip0EZEooUIXEYkSKnQRkSihQhcRiRIqdBGRKPH/AbBO7B1kvYrwAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = np.arange(-5,5,0.1)\n",
    "y = sigmoid(x)\n",
    "plt.plot(x,y)\n",
    "plt.ylim(-0.1,1.1)\n",
    "plt.show()"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T08:14:44.309769600Z",
     "start_time": "2023-08-27T08:14:42.063736200Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 3.2.6.非线性函数\n",
    "<P>事实上,阶跃函数与sigmoid函数都为非线性函数，线性函数是一种输出值为输入值常数倍的函数(y=cx).而非线性函数，指的是不像线性函数那样呈现出一条直线的函数</P>\n",
    "<P>神经网络必须使用非线性函数，换句话说，激活函数不能使用线性函数。因为如果使用线性函数的话，加深神经网络层次酒没有意义了</P>"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 3.2.7.ReLu函数.\n",
    "<P>Relu函数在输入值大于0时,直接输出该值。在输入值小于0时，直接输出0</P>"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6\n",
      "0\n"
     ]
    }
   ],
   "source": [
    "def relu(x):\n",
    "    return np.maximum(0,x)\n",
    "\n",
    "print(relu(6))\n",
    "print(relu(-8))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T08:55:44.523933Z",
     "start_time": "2023-08-27T08:55:44.514940300Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 3.3.多维数组的运算.\n",
    "<P>掌握多维数组的运算，能够快速地构建神经网络模型</P>"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2 3 4]\n",
      "1\n",
      "(4,)\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "### 3.3.1.多维数组\n",
    "import numpy as np\n",
    "A = np.array([1,2,3,4])\n",
    "print(A)\n",
    "print(np.ndim(A)) # 获取数组的维数\n",
    "print(A.shape) # 获取数组的维度\n",
    "print(A.shape[0]) # 获取数组第一维的形状"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T09:03:18.015245800Z",
     "start_time": "2023-08-27T09:03:17.989207800Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1 2]\n",
      " [3 4]\n",
      " [5 6]]\n",
      "(3, 2)\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "B = np.array([[1,2],[3,4],[5,6]])\n",
    "print(B)\n",
    "print(B.shape)\n",
    "print(np.ndim(B))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T09:04:36.633740900Z",
     "start_time": "2023-08-27T09:04:36.611455700Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2, 2)\n",
      "(2, 2)\n",
      "矩阵A与矩阵B:\n",
      "[[19 22]\n",
      " [43 50]]\n"
     ]
    }
   ],
   "source": [
    "### 3.3.2 矩阵乘法\n",
    "# 二维矩阵\n",
    "A = np.array([[1,2],[3,4]])\n",
    "print(A.shape)\n",
    "B = np.array([[5,6],[7,8]])\n",
    "print(B.shape)\n",
    "print('矩阵A与矩阵B:')\n",
    "print(np.dot(A,B))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T09:15:07.024873900Z",
     "start_time": "2023-08-27T09:15:07.003509800Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2, 3)\n",
      "(3, 2)\n",
      "矩阵A与矩阵B相乘\n",
      "[[22 28]\n",
      " [49 64]]\n"
     ]
    }
   ],
   "source": [
    "A = np.array([[1,2,3],[4,5,6]])\n",
    "print(A.shape)\n",
    "B = np.array([[1,2],[3,4],[5,6]])\n",
    "print(B.shape)\n",
    "print(\"矩阵A与矩阵B相乘\")\n",
    "print(np.dot(A,B))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T09:17:43.416201500Z",
     "start_time": "2023-08-27T09:17:43.404209400Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(3, 2)\n",
      "[[1 2]\n",
      " [3 4]\n",
      " [5 6]]\n",
      "(2,)\n",
      "[7 8]\n",
      "二者相乘\n",
      "[23 53 83]\n"
     ]
    }
   ],
   "source": [
    "A = np.array([[1,2],[3,4],[5,6]])\n",
    "print(A.shape)\n",
    "print(A)\n",
    "B = np.array([7,8])\n",
    "print(B.shape)\n",
    "print(B)\n",
    "print(\"二者相乘\")\n",
    "print(np.dot(A,B))"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T09:19:40.286799100Z",
     "start_time": "2023-08-27T09:19:40.261824500Z"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2,)\n",
      "[[1 3 5]\n",
      " [2 4 6]]\n",
      "(2, 3)\n",
      "[ 5 11 17]\n"
     ]
    }
   ],
   "source": [
    "### 3.3.3 神经网络的内积\n",
    "X = np.array([1,2])\n",
    "print(X.shape)\n",
    "W = np.array([[1,3,5],[2,4,6]])\n",
    "print(W)\n",
    "print(W.shape)\n",
    "Y = np.dot(X,W)\n",
    "print(Y)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T10:37:10.900079100Z",
     "start_time": "2023-08-27T10:37:10.873119100Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 3.4.三层神经网络的实现"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(2, 3)\n",
      "(2,)\n",
      "(2,)\n",
      "[0.3 0.7 1.1]\n",
      "[0.57444252 0.66818777 0.75026011]\n",
      "(3,)\n",
      "(3, 2)\n",
      "(2,)\n",
      "[0.31682708 0.69627909]\n"
     ]
    }
   ],
   "source": [
    "X = np.array([1,0.5])\n",
    "W1 = np.array([[0.1,0.3,0.5],[0.2,0.4,0.6]])\n",
    "B1 = np.array([0.1,0.2,0.3])\n",
    "\n",
    "print(W1.shape)\n",
    "print(X.shape)\n",
    "print(B.shape)\n",
    "\n",
    "A1= np.dot(X,W1)+B1\n",
    "\n",
    "Z1 = sigmoid(A1)\n",
    "print(A1)\n",
    "print(Z1)\n",
    "# 第二层网络\n",
    "W2 = np.array([[0.1,0.4],[0.2,0.5],[0.3,0.6]])\n",
    "B2 = np.array([0.1,0.2])\n",
    "\n",
    "print(Z1.shape)\n",
    "print(W2.shape)\n",
    "print(B2.shape)\n",
    "\n",
    "A2 = np.dot(Z1,W2) + B2\n",
    "Z2 = sigmoid(A2)\n",
    "\n",
    "# 最后是第二层到输出层的信号传递\n",
    "def identity_function(x):\n",
    "    return x\n",
    "\n",
    "W3 = np.array([[0.1,0.3],[0.2,0.4]])\n",
    "B3 = np.array([0.1,0.2])\n",
    "\n",
    "A3 = np.dot(Z2,W3) + B3\n",
    "Y = identity_function(A3)\n",
    "print(Y)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2023-08-27T11:08:50.447882Z",
     "start_time": "2023-08-27T11:08:50.434892100Z"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 3.5输出层的设计"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
